package com.fp.m7.shared.validator;

import org.springframework.stereotype.Component;

import com.fp.m7.shared.ValidationConstants;
import com.fp.m7.shared.ValidationError;
import com.fp.m7.shared.ValidationResult;

@Component
public class CommentValidator {

    public ValidationResult validate(String comment) {
        ValidationResult result = new ValidationResult();

        if (comment == null || !comment.matches(ValidationConstants.COMMENT_REGEX)) {
            result.add(new ValidationError(ValidationConstants.Fields.COMMENT, ValidationConstants.Messages.REGEX_FAIL));
        }

        return result;
    }

}
